﻿using System.Collections.Specialized;
using Newtonsoft.Json;

namespace CometDocs
{
    internal partial class Client
    {
        /// <summary>
        /// Create a new account: https://www.cometdocs.com/developer/apiDocumentation#method-createAccount
        /// </summary>
        /// <param name="name"></param>
        /// <param name="email"></param>
        /// <param name="password"></param>
        public void CreateAccount(string name, string email, string password)
        {
            NameValueCollection @params = new NameValueCollection(3);
            @params.Add("name", name);
            @params.Add("email", email);
            @params.Add("password", password);

            byte[] result = webClient.UploadValues(APIRoot + "createAccount", @params);

            string json = encoding.GetString(result);

            Response response = JsonConvert.DeserializeObject<Response>(json);

            CheckAndThrow(response);
        }
    }
}
